<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.css"/>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/general.css"/>
		<style type="text/css">
			.mui-content>.mui-table-view:first-child {
			    margin-top: 0px;
			}
			.mui-table-view-cell {
			    position: relative;
			    overflow: hidden;
			    padding: 0.8em 1em;
			    -webkit-touch-callout: none;
			}
			.listdiv{
				display: flex;
				justify-content: flex-start;
				align-items: center;
			}
			.listdiv img{
				height: 30px;
				border-radius: 50%;
				margin-right: 11px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">消息中心</h1>
		</header>
		<div class="mui-content" id="mlist">
		    
		</div>
		<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var rlist;
			window.onload = function(){
				mui.init();
				get_send_number();
				
			}
			
			//消息统计数量
			function get_send_number(){
				var data = {
					url:"/api/member/get_send_number",
					data:{
						access_token:acctoken(),
					}
				}
				ajax(data,function(res){
					console.log("消息统计数量",res)
					rlist = res.data;
					//console.log(slist);
					getmessagelist();
				})
			}
			//获取消息列表
			function getmessagelist(){
					var data = {
						url:"/api/message/lst",
						data:{
							access_token:acctoken()
						}
					}
					ajax(data,function(res){
						console.log(res);
						setmessagelist(res.data.data);
					})
			}
			function setmessagelist(data){
				var str = '<ul class="mui-table-view">';
				if(data.length){
					data.forEach(function(item,index){
						if(item.images&&item.images.path_name){
							str += '<li class="mui-table-view-cell" onclick="gopage('+item.id+')">'+
			            	'<a class="mui-navigate-right">'+
			             	'<div class=" listdiv">'+
			             	'<img src="'+item.images.path_name+'"/>'+
			             	item.name + '</div>';
			             	if(item.id == 1){
			             		str += '<span class="mui-badge mui-badge-danger">'+rlist.bithday_count+'</span>'
			             	}
			             	if(item.id == 2){
			             		str += '<span class="mui-badge mui-badge-danger">'+rlist.balance_count+'</span>'
			             	}
			             	if(item.id == 3){
			             		str += '<span class="mui-badge mui-badge-danger">'+rlist.long_count+'</span>'
			             	}
			             	if(item.id == 4){
			             		str += '<span class="mui-badge mui-badge-danger">'+rlist.pay_count+'</span>'
			             	}
			             	if(item.id == 6){
			             		str += '<span class="mui-badge mui-badge-danger">'+rlist.expire_count+'</span>'
			             	}
			             	if(item.id == 7){
			             		str += '<span class="mui-badge mui-badge-danger">'+rlist.product_count+'</span>'
			             	}
			             	if(item.id == 8){
			             		str += '<span class="mui-badge mui-badge-danger">'+rlist.time_count+'</span>'
			             	}
			             	str += '</a></li>';
						}
					})
				}
				str += '</ul>'
				g("mlist").innerHTML = str;
			}
			function gopage(cid){
				var list = {cid:cid}
				mui.openWindow({
					url:"childPages/messageToRemind.html?cid="+cid,
					id:"messageToRemind",
					extras:list
				})
			}
		</script>
	</body>

</html>